<template>
  <img class="code-img" :src="loginCodeImg" @click="getLoginCode" />
</template>
<script lang="ts">
  import { useUserStore } from '@/store/modules/user';
  import { defineComponent, ref } from 'vue';

  const props = {
    value: { type: [Object, Number, String, Array] },
  };

  export default defineComponent({
    name: 'LoginCodeImg',
    props,
    setup(_) {
      const loginCodeImg = ref<string>();
      const { loginCode } = useUserStore();
      const getLoginCode = async () => (loginCodeImg.value = await loginCode());
      getLoginCode();
      return {
        loginCodeImg,
        getLoginCode,
      };
    },
  });
</script>
<style scoped lang="less">
  .code-img {
    max-width: 100px;
    height: 100%;
  }
</style>
